package script.quizview
{
	import laya.events.Event;
	
	import model.quiz.MathQuizModel;
	
	import script.ViewManager;
	import script.baseView.BaseViewController;
	
	import ui.quiz.MathQuizSettingPanelUI;
	
	public class MathQuizSettingController extends BaseViewController
	{
		private var uiSkin:MathQuizSettingPanelUI;
		public function MathQuizSettingController()
		{
			super();
		}
		
		override public function onStart():void
		{
			uiSkin = this.owner as MathQuizSettingPanelUI;
			
			uiSkin.rangeinput.text = "10";
			
			uiSkin.opetype.selectedIndex = 0;
			
			uiSkin.numsize.selectedIndex = 0;
			
			uiSkin.startbtn.on(Event.CLICK,this,onClickStart);
			
		}
		
		private function onClickStart():void
		{
			
			MathQuizModel.instance.range = parseInt(uiSkin.rangeinput.text);
			MathQuizModel.instance.operateType = uiSkin.opetype.selectedIndex + 1;
			
			MathQuizModel.instance.numSize = uiSkin.numsize.selectedIndex + 2;
			
			MathQuizModel.instance.randomQuestion();
			
			ViewManager.instance.openView(ViewManager.VIEW_MATHQUIZ_PANEL,false);

		}
	}
}